local anyezhouyin = fk.CreateSkill {

  name = "anyezhouyin",

  tags = { Skill.Compulsory, },

}


Fk:loadTranslationTable{
  ["anyezhouyin"] = "暗夜咒印",
  [":anyezhouyin"] = "锁定技，当你造成伤害后，阻止目标下一次生命恢复。",

  ["#anyezhouyin"] = "暗夜咒印：锁定技，当你造成伤害后，阻止目标下一次生命恢复。",
  ["@jbstg_anyezhouyin-recover"] = "阻止生命恢复",
}

anyezhouyin:addEffect(fk.Damage, {
  name = "jbstg_anyezhouyin",
  anim_type = "offensive",
  events = {fk.Damage},
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(anyezhouyin.name) then
      return true
    end
  end,
  on_cost = function(self, event, target, player, data)
    return true
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local n=1
    player.room.logic:getEventsOfScope(GameEvent.ChangeHp, 1, function(e)
     local damage = e.data.damageEvent
     if  damage and player == damage.from then
       room:setPlayerMark(data.to, "@jbstg_anyezhouyin-recover", 1)
     end
   end, Player.HistoryGame)
  end,
})

anyezhouyin:addEffect(fk.PreHpRecover, {
  name = "#jbstg_anyezhouyin_delay",
  anim_type = "negative",
  events = {fk.PreHpRecover},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    if event == fk.PreHpRecover then
      return target:getMark("@jbstg_anyezhouyin-recover") > 0
    end
  end,
  on_cost = function(self, event, target, player, data)
    return true
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.PreHpRecover then
      room:setPlayerMark(target, "@jbstg_anyezhouyin-recover", 0)
      data:preventRecover()
    end
  end,
})

return anyezhouyin